package com.saw;


import java.util.ArrayList;
import java.util.Scanner;

public class StudentArrayListPro {



    public static void main(String[] args) {

   ArrayList<StudentPro> array = new ArrayList<StudentPro>();
   addStudent(array);
   addStudent(array);
   addStudent(array);

   for (int i=0;i<array.size();i++){
       StudentPro s = array.get(i);
       System.out.println(s.getName() + ","+ s.getAge());

   }







    }

    public static void addStudent(ArrayList<StudentPro> array){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入学生姓名");
        String name = sc.nextLine();
        System.out.println("请输入学生年龄");
        String age = sc.nextLine();

//       创建学生对象,把键盘录入的信息赋值给学生对象

        StudentPro s = new StudentPro();
        s.setAge(age);
        s.setName(name);

        array.add(s);

    }
}
